﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UFIDA.U9.AP.Enums;
using UFIDA.U9.CBO.FI.Enums;
using UFIDA.U9.CBO.SCM.Item;
using UFIDA.U9.InvDoc.Enums;
using UFSoft.UBF.Business;
using UFSoft.UBF.Eventing;

namespace UFIDA.U9.CusDev.QJKJPlugInBE
{
    class ProcessForMiscShipUpdate : IEventSubscriber
    {
        public void Notify(params object[] args)
        {

            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent)) return;
            BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;

            if (key == null || key.GetEntity() == null) return;
            //杂发单
            UFIDA.U9.InvDoc.MiscShip.MiscShipment MiscShip = key.GetEntity() as UFIDA.U9.InvDoc.MiscShip.MiscShipment;
            if (MiscShip == null) return;

            #region 私有5不为30时,不能点审核
            if (MiscShip.OriginalData.Status == INVDocStatus.Approving && MiscShip.Status == INVDocStatus.Approved)
            {
                if(MiscShip.DescFlexField.PrivateDescSeg5 =="" || MiscShip.DescFlexField.PrivateDescSeg5 == null)
                {
                    throw new Exception("请填写OA审核状态!");
                }
                if (MiscShip.DescFlexField.PrivateDescSeg5 != 30.ToString())
                {
                    throw new Exception("该单据在OA没有审核完成!");
                }
            }
            

            #endregion

        }

    }
}
